/**
 * 考试相关API接口
 */
import { get, post } from '@/utils/request.js'

/**
 * 获取考试列表
 * @param {Object} params - 查询参数
 * @param {number} params.page - 页码
 * @param {number} params.size - 每页数量
 * @param {string} params.status - 考试状态
 */
export const getExamList = (params = {}) => {
  return get('/exams', params)
}

/**
 * 获取考试详情
 * @param {string} id - 考试ID
 */
export const getExamDetail = (id) => {
  return get(`/exams/${id}`)
}

/**
 * 开始考试
 * @param {string} examId - 考试ID
 */
export const startExam = (examId) => {
  return post(`/exams/${examId}/start`)
}

/**
 * 提交答案
 * @param {Object} data - 答题数据
 */
export const submitAnswer = (data) => {
  return post('/exams/submit', data)
}

/**
 * 获取考试结果
 * @param {string} examId - 考试ID
 */
export const getExamResult = (examId) => {
  return get(`/exams/${examId}/result`)
}

/**
 * 获取考试历史
 */
export const getExamHistory = () => {
  return get('/exams/history')
}

/**
 * 获取考试题目
 * @param {string} examId - 考试ID
 */
export const getExamQuestions = (examId) => {
  return get(`/exams/${examId}/questions`)
}

export default {
  getExamList,
  getExamDetail,
  startExam,
  submitAnswer,
  getExamResult,
  getExamHistory,
  getExamQuestions
}